//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_MODEL_BASE_ANIMATION_H
#define _UX_MODEL_BASE_ANIMATION_H

#include "../CResource.h"
#include "IModel.h"

namespace Engine
{
namespace Resources
{

	//
	// Base Model Animation interface
	//

	class _EXPORT_ IBaseAnimation : public CResource
	{
	public:
		IBaseAnimation(const char *pFileName): CResource(pFileName) {}

		virtual bool GetAnimator(const CResourcePtr &pMesh, const array<IMaterialPtr> &aMaterials,
								  IBaseModelAnimatorPtr &pAnimator) = 0;
	};



	//
	// Base Model Animator interface
	//

	class _EXPORT_ IBaseModelAnimator : public IModel
	{
	protected:
		IBaseModelAnimator(const char *pFileName): IModel(pFileName) {}
		virtual ~IBaseModelAnimator() {}
		
	public:
		// update animation
		virtual bool Update(float fTimeDelta) = 0;

		// return bounding box for current frame (with interpolation)
		//reuse: bool GetBoundingBox(vec3 &vExtent, vec3 &vCenter) = 0;

		// set tracks array to blend animation
		virtual bool SetTracksCurrent(const uint32 *pTracks, uint uCount, uint uStartFrame = 0) = 0;

		// set current frame in track
		virtual bool SetCurrentFrame(uint32 uTrack, uint uFrame = 0) = 0;

		// set/get looping state
		virtual void SetLooping(bool bLooping) = 0;
		virtual bool GetLooping() const = 0;

		// return animation resource
		virtual bool GetAnimation(CResourcePtr &) = 0;


		inline  bool SetTracksCurrent(const uint32_array_t &aTracks, uint uStartFrame = 0)
		{
			return SetTracksCurrent( aTracks.ptr(), uint( aTracks.Count() ), uStartFrame );
		}

		template <uint I>
		inline  bool SetTracksCurrent(const uint32 (&aTracks)[I], uint uStartFrame = 0)
		{
			return SetTracksCurrent( aTracks, I, uStartFrame );
		}

		inline  bool SetTrackCurrent(uint32 uTrack, uint uStartFrame = 0)
		{
			return SetTracksCurrent( &uTrack, 1, uStartFrame );
		}
	};

//-------------------------------------------------------------------

}	// Resources
}	// Engine

#endif	// _UX_MODEL_BASE_ANIMATION_H